package livingarea.actions_impl;

import livingarea.actions.DethType;
import livingarea.Members.Beast;
import livingarea.Members.Pray;

/**
 * Class incapsulate <code> die() </code> method and realized death action of
 * pray fish.
 *
 * @author Muzalevskiy Vitaliy
 */
public class PrayDeath implements DethType {

    /**<code> Beast </code> object that delegate object of current class.*/
    private Beast beast;

    /**
     * Constructor for current class.
     *
     * @param beast - <code> Beast </code> object that delegate object of 
     *      current class.
     */
    public PrayDeath(Beast beast) {
        this.beast = beast;
    }

    /**
     * Current method make pray fish to die after specified number of
     * iterations.
     */
    @Override
    public void die() {
        if (beast.getLifeCount() == Pray.DEATH_TIME) {
            beast.getLivingArea().removeMember(beast);
            beast.getLivingArea().getStatistics().decreasePrayCount();
            beast.getLivingArea().getStatistics().increaseDieCount();
        }
    }
}
